import dataUtil.sparkConnect as db
import random


def create_table():
    cols =["item_id", "hasDoc", "medicalFee", "tuitionFee", "disasterLevelIn3days", "epidemicIn3days", "industryIncr"]
    db.create_item_table("antipoor", cols)
    db.create_index_table()


def random_insert_data(nums):
    for i in range(nums):
        item_id = str(i)
        hasDoc = "false" if random.randint(0, 1) == 0 else "true"
        medicalFee = ["0", "5000", "25000"][random.randint(0, 2)]
        tuitionFee = ["0", "5000", "12000"][random.randint(0, 2)]
        disasterLevelIn3days = str(random.randint(0, 5))
        epidemicIn3Days = "false" if random.randint(0, 1) == 0 else "true"
        industryIncr = ["-30", "0", "10"][random.randint(0, 2)]
        temp_item = [item_id, hasDoc, medicalFee, tuitionFee, disasterLevelIn3days, epidemicIn3Days, industryIncr]
        print(temp_item)
        db.insert_item_table("antipoor", temp_item)


if __name__ == "__main__":
    create_table()
    random_insert_data(300)
